local Zhongjian = fk.CreateSkill {
    name = "Zhongjian",
    anim_type = "control",
    tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["Zhongjian"] = "重舰",
  [":Zhongjian"] = "锁定技，你使用牌无距离限制，且除了你以外的所有目标本回合所有技能失效；每个回合结束时，你摸x张牌（X为该回合以此法技能失效的人数）",
  ["@Zhongjian_seal"] = "重舰封印",
  ["#Zhongjian_draw"] = "%from 的技能 【%arg】 被触发，摸了 %arg2 张牌",
  ["@@Zhongjian_seal-turn"] = "重舰",
}

-- 使用牌无距离限制
Zhongjian:addEffect("targetmod", {
    bypass_distances = function(self, player, skill, card, to)
        return player:hasSkill(Zhongjian.name)
    end,
})

-- 封印目标角色技能
Zhongjian:addEffect(fk.TargetSpecified, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(Zhongjian.name) and
    target == player and data.to ~= player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(data.to, "@@Zhongjian_seal-turn", 1)
  end,
})

-- 判断角色是否被重舰封印
Zhongjian:addEffect(fk.TurnEnd, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(Zhongjian.name) then
      local room = player.room
      local n = 0
      for _, p in ipairs(room:getOtherPlayers(player)) do
          for _, skill in ipairs(p.player_skills) do
            if not skill:isEffectable(p) then
              n = n + 1
              break
            end
          end
      end
      return n > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 0
    for _, p in ipairs(room:getOtherPlayers(player)) do
      for _, skill in ipairs(p.player_skills) do
        if not skill:isEffectable(p) then
          n = n + 1
          break
        end
      end
    end
    room:drawCards(player, n)
  end,
})

Zhongjian:addEffect("invalidity", {
    invalidity_func = function(self, from, skill)
        return from:getMark("@@Zhongjian_seal-turn") > 0 
    end
  })



return Zhongjian  